var PlayingIntro = false;

// Quick credit and contact info
function AuthorSplash(){ 
	Hint = new Array();
	Hint[0] = "Kooparoids is yet another"
	Hint[1] = "infamous original by";
	Hint[2] = "jonboy@stdnet.com ";
	Hint[3] = " ";
	CloudSplash(Hint);
} 

function ShowIntroStory() {
  var myimage;
  var StoryFont = "system.rfn";
  var buffed;
  PlayingIntro = true;
  SND_MarioTechnoShort = LoadSound("mariotechnoshort.ogg");

  setWindowBehavior(StoryFont, "", 1.25);
  setColours(CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(255,255,255,255));

 while (PlayingIntro) {
  
  // New image sequence
  myimage = LoadImage("Party2.png");

  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  SND_MarioTechnoShort.play(true);
  Story = new Array();
  Story[0] = "The year is 1986. ";
  Story[1] = "After their meteoric rise to the top of the gaming world ";
  Story[2] = "in 'Donkey Kong' and 'Mario Brothers,' Mario and Luigi are ";
  Story[3] = "living large in downtown Manhattan. ";
  Story[4] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  
  
  if (!PlayingIntro) {break;}

  // Single story bit
  Story = new Array();
  Story[0] = "However, their fortunes turn for the worse as they "; 
  Story[1] = "attempt to cash in with a half-baked sequel called ";
  Story[2] = "'Super Mario Brothers.'  Hard-core gamers quickly flock ";
  Story[3] = "to darker fare like 'The Smurfs' and 'Barbie Rhinoplasty.' ";
  Story[4] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Nintendo of America drives the final nail in the coffin "; 
  Story[1] = "that September, dumping SMB from its console package ";
  Story[2] = "in favor of the addictive 'SimJanitor.' ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);
  
  // New image sequence
  myimage = LoadImage("Graffiti2.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  SND_MarioTechnoShort.stop();
  PlaySound("music_die.wav");
  Story = new Array();
  Story[0] = "Six months later Luigi is found dead of a ";
  Story[1] = "massive heroin overdose on the streets of LA. ";
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);
  
  // New image sequence
  myimage = LoadImage("UnderWater3.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  PlaySound("music_gameover.wav");
  Story = new Array();
  Story[0] = "The same week Mario fails to square with his bookie";
  Story[1] = "and is sent to sleep with the fishes...";
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);

  // New image sequence
  myimage = LoadImage("NuclearBlast1.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  PlaySound("nuke.wav");
  Story = new Array();
  Story[0] = "Sixteen years pass...  It is now 2002.  ";
  Story[1] = "After nuking Iraq to improve his sagging popularity, ";
  Story[2] = "President Bush is faced with a ridiculous crisis. ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);
  
  // New image sequence
  myimage = LoadImage("WhiteHouse2.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  SND_MarioTechnoShort.play(true);
  Story = new Array();
  Story[0] = "Mutation-enhanced beetles, turtles and even mushrooms "
  Story[1] ="threaten the stability of the free world. ";
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Bush: 'Dude, these shrooms are gnarlier ";
  Story[1] = "than the ones I did in high school!' "; 
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Dick: 'F--k the shrooms, dips--t. ";  
  Story[1] = "A little green turtle just took out NORAD!' "; 
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);
  
  // New image sequence
  myimage = LoadImage("BushCheney3.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  Story = new Array();
  Story[0] = "Bush: 'Did you say turtles? ";
  Story[1] = "Well I just played this Nesticle ROM where some plumber "
  Story[2] = "kicks the snot out of all kinds of mean, mean turtles... "
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Dick: 'You f--king numbnut! ";
  Story[1] = "You just played Super Mario Brothers, the Waterworld,";
  Story[2] = "the Ishtar, the Episode I of mid-1980's gaming.' ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Bush: 'Yeah, well my daddy said I'm still president. ";
  Story[1] = "Let's just get that greasy little man up here today ";
  Story[2] = "and see what he can do.' ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Dick: 'Idiot.  What a f--king balloonhead.' ";  
  Story[1] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);

  // New image sequence
  myimage = LoadImage("MarioInSpace.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  Story = new Array();
  Story[0] = "Top scientists pull Mario's preserved body from the ";
  Story[1] = "Hudson river. After being revived, a flame cannon "
  Story[2] = "is mounted in his skull and he is launched into space "
  Story[3] = "to battle evil. ";
  Story[4] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "As soon as Mario reaches low earth orbit, Goombas, Koopas ";
  Story[1] = "and Buzzy Beetles around the world break off their attacks ";
  Story[2] = "and head instead for their arch enemy. ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);

  // New image sequence
  myimage = LoadImage("BushCheney3.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  Story = new Array();
  Story[0] = "Bush: 'Hooray, hooray! ";
  Story[1] = "Mario's drawing them away. "
  Story[2] = "We're saved!' "
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "Dick: 'Is it too late to throw the election ";
  Story[1] = "in favor of Gore?' ";
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  FadeOutStoryImage(600,myimage);

  // New image sequence
  myimage = LoadImage("MarioSwarm.png");

  if (!PlayingIntro) {break;}
  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  Story = new Array();
  Story[0] = "Meanwhile...in space... ";
  Story[1] = "Mario faces off against the evil swarm. "
  Story[2] = "The fate of humanity hangs in the balance. "
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // Single story bit
  Story = new Array();
  Story[0] = "May you fight bravely.";
  Story[1] = "(Okay, already.  That's enough backstory! ";
  Story[2] = "Enjoy the game.  - jonboy@stdnet.com) ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  if (!PlayingIntro) {break;}
  // End image sequence
  SND_MarioTechnoShort.stop();
  FadeOutStoryImage(600,myimage);

  PlayingIntro = false;

 }

  if (SND_MarioTechnoShort.isPlaying()) {SND_MarioTechnoShort.stop();}

//  ClearScreen();  
//  FlipScreen();  
}

function FadeOutStoryImage(msecs, storyimage)
{
//  var image = GrabImage(0, 0, GetScreenWidth(), GetScreenHeight());
//  var color = CreateColor(clr.red, clr.green, clr.blue, clr.alpha);
  var color = CreateColor(0, 0, 0, 255);

  var time = GetTime();
  while (GetTime() - time < msecs) {
    color.alpha = (GetTime() - time) * 255 / msecs;
    // image.blit(0, 0);
    storyimage.blit(6, 6);
    ApplyColorMask(color);
    FlipScreen();
  }

  color.alpha = 255;
  // image.blit(0, 0);
  storyimage.blit(6, 6);
  ApplyColorMask(color);
  FlipScreen();

  // image.blit(0, 0);
  storyimage.blit(6, 6);
}

function PlayFinale() {

  SetFrameRate(0);

  var myimage;
//  var buffed;
  var Story;
  var StoryFont = "system.rfn";
  setWindowBehavior(StoryFont, "", 1.25);
  setColours(CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(0,0,0,100), CreateColor(255,255,255,255));
  
  // New image sequence
  myimage = LoadImage("BushCheney3.png");

  // First story bit
  myimage.blit(6, 6);
  FadeIn(600);
  Story = new Array();
  Story[0] = "Bush: 'I can't believe that greasy little plumber got our ";
  Story[1] = "fat asses out of that jam.  If I wasn't so high I'd probably ";
  Story[2] = "make him a Supreme Court Justice, or something...' ";
  Story[3] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  
  
//  if (!PlayingIntro) {break;}

  // Single story bit
  Story = new Array();
  Story[0] = "Cheney: 'That f---ing does it. Quayle campaign, "; 
  Story[1] = "here I come!' ";
  Story[2] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  // Single story bit
  Story = new Array();
  Story[0] = "To Be Continued... "; 
  Story[1] = "(Your final score was " + MarioScore + ".)";
  Story[2] = " ";
  Story[3] = "Thanks for playing Kooparoids - jonboy@stdnet.com. ";
  Story[4] = " ";
  drawLeftStoryMessage(18,332,Story,25,myimage);  

  // End image sequence
  FadeOutStoryImage(600,myimage);
  
}
